Skip to content

fix(sentry): filter TransformStream noise and close E2E detection gap for on_request_error events#1145

Merged
sw-factory-automations merged 1 commit into
mainfrom
fix/sentry-memo-2g-transformstream-e2e-filter-gap
May 18, 2026
Merged

fix(sentry): filter TransformStream noise and close E2E detection gap for on_request_error events#1145
sw-factory-automations merged 1 commit into
mainfrom
fix/sentry-memo-2g-transformstream-e2e-filter-gap

Conversation

@sw-factory-automations
Copy link
Copy Markdown
Collaborator

Summary

Fixes two related issues that allow noise to reach Sentry from E2E test sessions.

Sentry issue: https://ona-2j.sentry.io/issues/120744596/ (MEMO-2G)

Closes #1144

Root Cause

1. TransformStream noiseTypeError: controller[kState].transformAlgorithm is not a function is a known Node.js internal web streams race condition during SSR (vercel/next.js#68319, vercel/next.js#75994). Stack trace contains only Node.js internals — no app code. Not fixable in our codebase.

2. E2E filter gap — Next.js's captureRequestError (onRequestError hook) sets request headers in scope.sdkProcessingMetadata.normalizedRequest but does NOT populate event.request. Sentry's ingestion pipeline enriches event.contexts.browser after beforeSend runs on the server. So isE2ETestRequest had no way to detect HeadlessChrome for on_request_error events.

Changes

  • src/lib/sentry/event-filters.ts — Add transformAlgorithm is not a function to NEXTJS_INTERNAL_NOISE_PATTERNS
  • src/lib/sentry/e2e-detection.ts — Add isolation scope fallback: read getIsolationScope().getScopeData().sdkProcessingMetadata.normalizedRequest.headers for HeadlessChrome detection when event.request is null and event.contexts.browser is unavailable
  • src/lib/sentry/sentry.unit.test.ts — 9 new tests covering TransformStream filtering, scope-based E2E detection (positive/negative), and shouldDropServerEvent integration
  • .agents/conventions.md — Document the four-source E2E detection strategy

Test Results

pnpm lint && pnpm typecheck && pnpm test — all 1962 tests pass, 0 errors.

… for on_request_error events

Add TransformStream 'transformAlgorithm is not a function' to
isNextjsInternalNoise — a known Node.js web streams race condition
during SSR with no app code in the stack trace.

Add isolation scope fallback to isE2ETestRequest. Next.js's
captureRequestError sets request headers in sdkProcessingMetadata
but not in event.request, and event.contexts.browser is enriched
by Sentry's ingestion pipeline after beforeSend runs. The new
fallback reads the scope's normalizedRequest headers directly.

Closes #1144

Co-authored-by: Ona <no-reply@ona.com>
@sw-factory-automations sw-factory-automations added the bug Something isn't working label May 18, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
memo Ready Ready Preview, Comment May 18, 2026 2:15pm

Request Review

@sw-factory-automations sw-factory-automations merged commit acc4e81 into main May 18, 2026
9 checks passed
@sw-factory-automations sw-factory-automations deleted the fix/sentry-memo-2g-transformstream-e2e-filter-gap branch May 18, 2026 14:33
@sw-factory-automations
Copy link
Copy Markdown
Collaborator Author

✅ UI verification skipped — no UI files changed. This PR modifies only Sentry event filtering logic (src/lib/sentry/) and documentation (.agents/conventions.md).

@sw-factory-automations
Copy link
Copy Markdown
Collaborator Author

✅ Post-merge verification passed.

E2E tests (26/26 passed):

  • Authentication: sign-in/sign-up page rendering, form validation, sign-in redirect, sign-out flow
  • Public routes: landing page, SEO routes (robots.txt, sitemap.xml, opengraph-image, twitter-image)
  • Health API: /api/health returns successful response
  • Auth redirects: protected routes redirect unauthenticated users to /sign-in

Ad-hoc smoke tests (all passed):

  • Landing page: loaded, has title
  • /sign-in: rendered with email input
  • /api/health: returned OK
  • Authenticated flow: login succeeded, workspace page loaded

Skipped:

  • /dashboard (route does not exist — returns 404)
  • Editor navigation (no page buttons found in test workspace)
  • Interaction smoke test skipped (PR is fix:, not feat:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: E2E filter misses on_request_error events; TransformStream noise reaches Sentry (Sentry MEMO-2G)

1 participant